package com.hui.server.controller;

import com.hui.server.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.sql.SQLIntegrityConstraintViolationException;
import java.util.Date;

/**
 * @BelongsProject: yeb
 * @BelongsPackage: com.hui.server.controller
 * @Author: HUI
 * @CreateTime: 2022-04-04 11:08
 * @Description: 测试 Controller
 */

@RestController
public class HelloController {

    @Autowired
    private MenuService menuService;

    @GetMapping("/hello")
    public String hello() {
        return "index ok";
    }


    /**
     * 测试id为2 的用户可以访问的路径
     * @return
     */
    @GetMapping("/employee/basic/hello")
    public String getBase(){
        return "可以访问！";
    }



    /**
     * 测试id为2 的用户不可以访问的路径
     * @return
     */
    @GetMapping("/system/init/hello")
    public String getNeedRole(){
        return "测试用户不可以访问的！";
    }


    @GetMapping("/err")
    public String testErr(){
        if (new Date().getTime()>10000000)
        throw new NullPointerException("自定义控制器出现异常！");
        return "没有出现异常";
    }


    @GetMapping("/err2")
    public String testErr2() throws SQLIntegrityConstraintViolationException {
        if (new Date().getTime()>10000000)
            throw new SQLIntegrityConstraintViolationException("自定义控制器出现异常！");
        return "没有出现异常";
    }
}
